<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <body>

        <ui:composition template="./../index.xhtml">
            <ui:define name="title">Danh sách bài viết</ui:define>
            <ui:define name="sum1">
                <div class="row" style="background-color: #efefef">
                    <div class="container" style="display: block;background-color: #e7e7e7">
                        <div class="row">
                            <div class="col-md-9">
                                <div class="row">
                                    <b class="col-md-8 singup" style="margin-bottom: 10px">DANH SÁCH BÀI VIẾT</b>
                                </div>
                                <div class="row">
                                    <div class="col-md-12">
                                        <h:form>
                                            <ui:repeat value="#{postManagement.posts}" var="post">
                                                <div class="row border-bottom-post">
                                                    <div class="col-md-1">
                                                        <img class="bvdqt-img post-bg" src="#{application.contextPath}/resources/#{post.user.avatarPath}" alt=""/>
                                                    </div>
                                                    <div class="col-md-8">
                                                        <h:commandLink action="/modules/posts.jsf" 
                                                                       actionListener="#{postManagement.addViewer(post.postId)}" value="#{post.title}"
                                                                       class="post-list"/><br />
                                                        <h:commandLink action="/modules/posts.jsf" 
                                                                       value="#{post.user.userName}" class="post-user"/>, 
                                                        <c:if test="#{post.updateDate == null}">
                                                            <h:outputLabel class="post-info" value="#{post.createDate}">
                                                                <f:convertDateTime pattern="dd-MM-yyyy"/>
                                                            </h:outputLabel>
                                                        </c:if>
                                                        <c:if test="#{post.updateDate != null}">
                                                            <h:outputLabel class="post-info" value="#{post.updateDate}">
                                                                <f:convertDateTime pattern="dd-MM-yyyy"/>
                                                            </h:outputLabel>
                                                        </c:if>
                                                    </div>
                                                    <div class="col-md-1">
                                                        <span class="post-user">#{post.viewCount}</span><br/>
                                                        <span class="post-user">#{post.comments.size()}</span>
                                                    </div>
                                                    <div class="col-md-2">
                                                        <c:if test="#{post.comments.size() != 0}">
                                                        <h:commandLink action="/modules/posts.jsf" 
                                                                           value="#{postManagement.getLastComment(post).user.userName}"
                                                                           class="post-user-comment"/> <br/>
                                                        <h:outputLabel class="post-info"
                                                                       value="#{postManagement.getLastComment(post).updateDate}">
                                                            <f:convertDateTime locale="vi_VN" type="both" pattern="EEEE, dd-MM-yyyy"  />
                                                        </h:outputLabel>
                                                        </c:if>
                                                    </div>
                                                </div>
                                            </ui:repeat>
                                        </h:form>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="row">
                                    <b class="col-md-12 singup" style="margin-bottom: 10px">DANH MỤC</b>
                                </div>
                                <div class="row bvdqt-bg">
                                    <div class="col-md-12">
                                        <h:form>
                                            <ui:repeat value="#{categoryBean.categorys}" var="category">
                                                <p class="border-bottom"> <h:commandLink action="#" value="#{category.categoryName}" class="bvdqt"/></p>
                                            </ui:repeat>
                                        </h:form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </ui:define>

        </ui:composition>

    </body>
</html>
